home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htaaserv.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  4.9 KB  |  145 lines

  1. /*                          SERVER SIDE ACCESS AUTHORIZATION MODULE
  2.                                              
  3.    This module is the server side interface to Access Authorization (AA) package. It
  4.    contains code only for server.
  5.    
  6.    Important to know about memory allocation:
  7.    
  8.    Routines in this module use dynamic allocation, but free automatically all the memory
  9.    reserved by them.
  10.    
  11.    Therefore the caller never has to (and never should) free() any object returned by
  12.    these functions.
  13.    
  14.    Therefore also all the strings returned by this package are only valid until the next
  15.    call to the same function is made. This approach is selected, because of the nature of
  16.    access authorization: no string returned by the package needs to be valid longer than
  17.    until the next call.
  18.    
  19.    This also makes it easy to plug the AA package in: you don't have to ponder whether to
  20.    free()something here or is it done somewhere else (because it is always done somewhere
  21.    else).
  22.    
  23.    The strings that the package needs to store are copied so the original strings given as
  24.    parameters to AA functions may be freed or modified with no side effects.
  25.    
  26.    Also note:The AA package does not free() anything else than what it has itself
  27.    allocated.
  28.    
  29.  */
  30.  
  31. #ifndef HTAASERV_H
  32. #define HTAASERV_H
  33.  
  34. #include <stdio.h>              /* FILE                 */
  35. #include "HTUtils.h"            /* BOOL, PARAMS, ARGS   */
  36. #include "HTRules.h"            /* This module interacts with rule system */
  37. #include "HTAAUtil.h"           /* Common parts of AA   */
  38. #include "HTAuth.h"             /* Authentication       */
  39.  
  40.  
  41. #ifdef SHORT_NAMES
  42. #define HTAAstMs        HTAA_statusMessage
  43. #define HTAAchAu        HTAA_checkAuthorization
  44. #define HTAAcoAH        HTAA_composeAuthHeaders
  45. #define HTAAsLog        HTAA_startLogging
  46. #endif /*SHORT_NAMES*/
  47.  
  48. /*
  49.  
  50. Check Access Authorization
  51.  
  52.    HTAA_checkAuthorization() is the main access authorization function.
  53.    
  54.  */
  55.  
  56. /* PUBLIC                                             HTAA_checkAuthorization()
  57. **              CHECK IF USER IS AUTHORIZED TO ACCESS A FILE
  58. ** ON ENTRY:
  59. **      url             is the document to be accessed.
  60. **      method_name     name of the method, e.g. "GET"
  61. **      scheme_name     authentication scheme name.
  62. **      scheme_specifics authentication string (or other
  63. **                      scheme specific parameters, like
  64. **                      Kerberos-ticket).
  65. **
  66. ** ON EXIT:
  67. **      returns status codes uniform with those of HTTP:
  68. **        200 OK           if file access is ok.
  69. **        401 Unauthorized if user is not authorized to
  70. **                         access the file.
  71. **        403 Forbidden    if there is no entry for the
  72. **                         requested file in the ACL.
  73. **
  74. ** NOTE:
  75. **      This function does not check whether the file
  76. **      exists or not -- so the status  404 Not found
  77. **      must be returned from somewhere else (this is
  78. **      to avoid unnecessary overhead of opening the
  79. **      file twice).
  80. **
  81. */
  82. PUBLIC int HTAA_checkAuthorization PARAMS((CONST char * url,
  83.                                            CONST char * method_name,
  84.                                            CONST char * scheme_name,
  85.                                            char *       scheme_specifics));
  86. /*
  87.  
  88. Compose Status Line Message
  89.  
  90.  */
  91.  
  92. /* SERVER PUBLIC                                        HTAA_statusMessage()
  93. **              RETURN A STRING EXPLAINING ACCESS
  94. **              AUTHORIZATION FAILURE
  95. **              (Can be used in server reply status line
  96. **               with 401/403 replies.)
  97. ** ON EXIT:
  98. **      returns a string containing the error message
  99. **              corresponding to internal HTAAFailReason.
  100. */
  101. PUBLIC char *HTAA_statusMessage NOPARAMS;
  102. /*
  103.  
  104. Compose "Authenticate:" Header Lines for Server Reply
  105.  
  106.  */
  107.  
  108. /* SERVER PUBLIC                                    HTAA_composeAuthHeaders()
  109. **              COMPOSE WWW-Authenticate: HEADER LINES
  110. **              INDICATING VALID AUTHENTICATION SCHEMES
  111. **              FOR THE REQUESTED DOCUMENT
  112. ** ON ENTRY:
  113. **      No parameters, but HTAA_checkAuthorization() must
  114. **      just before have failed because a wrong (or none)
  115. **      authentication scheme was used.
  116. **
  117. ** ON EXIT:
  118. **      returns a buffer containing all the WWW-Authenticate:
  119. **              fields including CRLFs (this buffer is auto-freed).
  120. **              NULL, if authentication won't help in accessing
  121. **              the requested document.
  122. */
  123. PUBLIC char *HTAA_composeAuthHeaders NOPARAMS;
  124. /*
  125.  
  126. Start Access Authorization Logging
  127.  
  128.  */
  129.  
  130. /* PUBLIC                                               HTAA_startLogging()
  131. **              START UP ACCESS AUTHORIZATION LOGGING
  132. ** ON ENTRY:
  133. **      fp      is the open log file.
  134. **
  135. */
  136. PUBLIC void HTAA_startLogging PARAMS((FILE * fp));
  137. /*
  138.  
  139.  */
  140.  
  141. #endif  /* NOT HTAASERV_H */
  142. /*
  143.  
  144.    End of file HTAAServ.h.  */
  145.